package com.swpu.project.controller;


import com.swpu.project.common.BaseResponse;
import com.swpu.project.model.entity.Mineral;
import com.swpu.project.service.IMineralService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author swpuyanxiegroup1
 * @since 2024-07-29
 */
@RestController
@RequestMapping("/data")
public class MineralController {


    @Resource
    IMineralService iMineralService;




    @PreAuthorize("@verf.hasAnyAuthorityForBlock('sys_query')")
    @GetMapping("/mineral/query/{id}")
    BaseResponse queryData(@PathVariable(name="id") String belongId)
    {

       return iMineralService.queryData(belongId);



    }


    @PutMapping("/mineral/update")
    @PreAuthorize("@verf.hasAnyAuthorityForBlock('sys_update')")
    BaseResponse updateMineral(@RequestBody List<Mineral> minerals,@RequestParam(name = "block") String blockNum)
    {

         return iMineralService.updateMineral( minerals,blockNum);

    }

@DeleteMapping("/mineral/delete")
@PreAuthorize("@verf.hasAnyAuthorityForBlock('sys_update')")
BaseResponse deleteMineral(@RequestBody List<Mineral> minerals,
                           @RequestParam(name = "block") String blockNum)
{

    return iMineralService.deleteMineral( minerals,blockNum);

}





}
